package com.rx.mine.controller;

import com.rx.core.base.RxBaseConstant;
import com.rx.core.base.RxBaseController;
import com.rx.mine.service.MineService;
import com.rx.mine.vo.AppLoginVo;
import com.rx.mine.vo.AppRecordVo;
import com.rx.mine.vo.BattleVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(RxBaseConstant.CONFIG_COMMON_API)
@Slf4j
public class MineController extends RxBaseController {

    @Autowired
    MineService mineService;

    @PostMapping(value = "/app-login")
    public Object appLogin(@RequestBody AppLoginVo appLoginVo) throws IllegalAccessException, InstantiationException {
        return mineService.appLogin(appLoginVo);
    }

    @PostMapping(value = "/sign")
    public Object sign(@RequestBody AppLoginVo appLoginVo) throws IllegalAccessException, InstantiationException {
        return mineService.sign(appLoginVo);
    }

    @PostMapping(value = "/consume")
    public Object consume(@RequestBody AppLoginVo appLoginVo) throws IllegalAccessException, InstantiationException {
        return mineService.consume(appLoginVo);
    }


    @PostMapping(value = "/record")
    public Object record(@RequestBody AppRecordVo appRecordVo) throws IllegalAccessException, InstantiationException {
        return mineService.record(appRecordVo);
    }

    @PostMapping(value = "/search")
    public Object search(@RequestBody AppRecordVo appRecordVo) throws IllegalAccessException, InstantiationException {
        return mineService.search(appRecordVo);
    }

    @PostMapping(value = "/battle")
    public Object battle(@RequestBody BattleVo battleVo) throws IllegalAccessException, InstantiationException {
        return mineService.battle(battleVo);
    }

    /**
     * 获取分数排名、最新对战。本人对战情况
     * @param battleVo
     * @return
     * @throws IllegalAccessException
     * @throws InstantiationException
     */
    @PostMapping(value = "/battle-search")
    public Object battleSearch(@RequestBody BattleVo battleVo) throws IllegalAccessException, InstantiationException {
        return mineService.battleSearch(battleVo);
    }
}
